﻿<!--/* 
* Copyright (c) 2009, The University of Texas at Austin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, 
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, 
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, 
* this list of conditions and the following disclaimer in the documentation and/or other materials 
* provided with the distribution.
*
* Neither the name of The University of Texas at Austin nor the names of its contributors may be 
* used to endorse or promote products derived from this software without specific prior written 
* permission.
* 
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/-->
    
<Window x:Class="Bio.Views.BioFloatingWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="{Binding Title}" AllowsTransparency="True"
    WindowStartupLocation="CenterScreen" ShowInTaskbar="True" Icon="{Binding ImageUrl}"
    WindowStyle="None" ResizeMode="CanResizeWithGrip" Background="Transparent" MinWidth="200" MinHeight="200">
    
    <Border BorderBrush="Black" BorderThickness="1" CornerRadius="5">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <Rectangle Fill="Gray" Opacity=".6" Grid.RowSpan="2" Stroke="White" StrokeThickness="2">
                <Rectangle.Effect>
                    <BlurEffect />
                </Rectangle.Effect>
            </Rectangle>

            <Rectangle Stroke="White" StrokeThickness="1" Grid.RowSpan="2" RadiusX="5" RadiusY="5" />
            
            <DockPanel Grid.Row="0" Margin="4,2">
                <ToggleButton DockPanel.Dock="Left" Margin="2,2,4,2"  IsTabStop="False"
                              VerticalAlignment="Center" HorizontalAlignment="Center"
                              Style="{DynamicResource TogglePin}"
                              IsChecked="{Binding Visual.DataContext.IsDocked}" />

                <Button Click="OnClose" DockPanel.Dock="Right" Padding="8,1" Margin="0,0,0,2" IsTabStop="False" ToolTip="Close">
                    <Path Stroke="Black" Fill="White" StrokeThickness="1" RenderTransformOrigin=".5,.5"
                          Data="M8.5920424,0.5 L10.341043,0.5 10.341043,8.5889425 18.429971,8.574542 18.433085,10.323539 10.341043,10.337945 10.341043,18.43 8.5920424,18.43 8.5920424,10.341058 0.50311327,10.355458 0.5,8.6064615 8.5920424,8.5920553 z">
                        <Path.RenderTransform>
                            <RotateTransform Angle="45" />
                        </Path.RenderTransform>
                    </Path>
                </Button>
                <Button Click="OnMaximize" DockPanel.Dock="Right" Padding="8,1" Margin="0,0,0,2" IsTabStop="False" ToolTip="Maximize">
                    <Path Stroke="Black" Fill="White" StrokeThickness="1" 
                          Data="M2.5033089,2.4140001 L2.5033089,12.21 12.563808,12.21 12.563808,2.4140001 z M0.5,0.5 L14.469,0.5 14.469,14.222 0.5,14.222 z"
                               Margin="1" />
                </Button>
                <Button Click="OnMinimize" DockPanel.Dock="Right" Padding="8,1" Margin="0,0,0,2" IsTabStop="False" ToolTip="Minimize">
                    <Rectangle Stroke="Black" Fill="White" StrokeThickness="1" Width="10" Height="4" Margin="1"  />
                </Button>

                <Grid DockPanel.Dock="Left" Margin="5,2" Background="Transparent" MouseLeftButtonDown="OnDoubleClickMaximize" MouseDown="OnMouseDrag">
                    <Rectangle Fill="White" Opacity=".75" RadiusX="8" RadiusY="8">
                        <Rectangle.Effect>
                            <BlurEffect Radius="8" />
                        </Rectangle.Effect>
                    </Rectangle>
                    <TextBlock VerticalAlignment="Center"
                           Text="{Binding Title, FallbackValue=Title_Goes_Here}" 
                           Foreground="{x:Static SystemColors.WindowTextBrush}" 
                           FontWeight="Bold" />
                </Grid>

            </DockPanel>
            
            <Border x:Name="ContentBorder" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Background="#FF595959" Margin="3">
                <ContentControl Content="{Binding Visual}" 
                            Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
            </Border>
            
        </Grid>
        
    </Border>        
</Window>
